<div class="giveHeight"> 
    <table class="responsive dynamicTable display table table-bordered dataTable">
        <thead>        
            <tr>
{# sorting of properties based on query components #}
                    {{ knp_pagination_sortable(pagination, 'N° Devis', 'd.reference') }}
                                {{ knp_pagination_sortable(pagination, 'Raison Social', 'd.client') }}
                <th>Date</th>
                <th>Heure</th>
                <th>Montant TTc</th>
                <th>Action</th>
            </tr>
        </thead>

{# table body #}
{% for devis in pagination %}
        <tr {% if loop.index is odd %}class="color"{% endif %}>
            <td style="width:10%;text-align: center">{{ devis.reference }}</td>
            <td style="width:15%">{{ devis.client }}</td>
            <td style="width:15%">{{ devis.date|date('d/m/Y') }} </td>
            <td style="width:15%"> {{ devis.getTime }}</td>
            <td style="width:15%">{{ devis.montantTtc }}</td>
            <td class="center ">
                <div class="controls center">
                    <a class="tip" href="javascript:showDevis('{{devis.id}}')" title="Visualiser">
                        <span class="icon12 icon-eye-open"></span>
                    </a>
                    <a style="padding-left:5%"class="tip" href="javascript:editDevis('{{devis.id}}')" title="Modifier">
                        <span class="icon12 icon-pencil"></span>
                    </a>
                    <a  style="padding-left:5%" class="tip" href="javascript:duppliquerDevis('{{devis.id}}')" title="Duppliquer">
                        <span class="icon12 icomoon-icon-google-plus-2 "></span>
                    </a>                            
                    <a  style="padding-left:5%" class="tip" href="javascript:imprimerDevis('{{devis.id}}')" title="Imprimer">
                        <span class="icon12 icon-print"></span>
                    </a>
                        
                    <a  style="padding-left:10%" class="tip" href="javascript:commanderDevis('{{devis.id}}')" title="Commander">
                        <span class="brocco-icon-cart"></span>
                    </a>
                    <a  style="padding-left:5%" class="tip" href="javascript:livrerDevis('{{devis.id}}')" title="Livrer">
                        <span class="icon12 icomoon-icon-out-2"></span>
                    </a>
                            {% if is_granted('ROLE_SUPER_ADMIN') %}
                    <a style="padding-left:10%" class="tip" href="javascript:removeDevis('{{devis.id}}')" title="Supprimer">
                        <span class="icon12 icomoon-icon-remove"></span>
                    </a>
                            {% endif %}
                       
                </div>
            </td>
        </tr>
{% endfor %}
    </table>
</div>
<div id="DataTables_Table_0_info" class="dataTables_info">Affichage de {{ (pagination.getCurrentPageNumber -1)*pagination.getItemNumberPerPage + 1}} à {{ (pagination.getCurrentPageNumber -1)*pagination.getItemNumberPerPage + pagination.getItemNumberPerPage}} de {{ pagination.getTotalItemCount }} Devis</div>
{# display navigation #}
<div id="DataTables_Table_0_paginate" class="dataTables_paginate paging_full_numbers">
    {{ knp_pagination_render(pagination) }}
</div>
<script>

    function showDevis(id) {
        lf = remplirlf()
        $.ajax({
            url: '{{path('gds_devis_show')}}',
            data: 'id=' + id,
            success: function(data) {
                $('#div_liste_devis').html(data)
            }
        })
    }
    function editDevis(id) {
        lf = remplirlf()
        $.ajax({
            url: '{{path('gds_devis_edit')}}',
            data: 'id=' + id,
            success: function(data) {
                $('#div_liste_devis').html(data)
            }
        })
    }
    function duppliquerDevis(id) {
        lf = remplirlf()
        $.ajax({
            url: '{{path('gds_devis_duppliquer')}}',
            data: 'id=' + id,
            success: function(data) {
                $('#div_liste_devis').html(data)
            }
        })
    }
    function imprimerDevis(id) {
        $.ajax({
            url: '{{path('gds_devis_print_saved')}}',
            type: "POST",
            data: "id=" + id,
            success: function(data) {
                $.msgBox({
                    title: "Devis",
                    content: "Imression effectué avec succés",
                    type: "info"
                });
            }
        })
    }
    function commanderDevis(id) {
        lf = remplirlf()
        $.ajax({
            url: '{{path('gds_devis_commander')}}',
            data: 'id=' + id,
            success: function(data) {
                $('#div_liste_devis').html(data)
            }
        })
    }
    function livrerDevis(id) {
        lf = remplirlf()
        $.ajax({
            url: '{{path('gds_devis_livrer')}}',
            data: 'id=' + id,
            success: function(data) {
                $('#div_liste_devis').html(data)
            }
        })
    }
    function remplirlf() {
        var liste_f = new Array()
        liste_f[0] = $('#filtre_numero').val()
        liste_f[1] = $('#filtre_raison_social').val()
        liste_f[2] = date1
        liste_f[3] = date2
        liste_f[4] = heure1
        liste_f[5] = heure2
        liste_f[6] = $('#filtre_reference').val()
        liste_f[7] = $('#filtre_designation').val()
        liste_f[8] = $('#filtre_ttc1').val()
        liste_f[9] = $('#filtre_ttc2').val()
        liste_f[10] = $('#filtre_type').val()
        return liste_f
    }


     {% if is_granted('ROLE_SUPER_ADMIN') %}
    function removeDevis(id) {
        $.msgBox({
            title: "Suppression Devis",
            content: "Voulez-vous placer le devis dans la corbeille ?",
            type: "confirm",
            buttons: [{value: "OUI"}, {value: "NON"}, {value: "Annuler"}],
            success: function(result) {
                if (result == "OUI") {
                    $.ajax({
                        url: '{{path('gds_devis_delete')}}',
                        data: 'id=' + id,
                        success: function(data) {
                            $.msgBox({
                                title: "Devis",
                                content: "Devis placé dans la corbeille",
                                type: "info",
                                buttons: [{value: "OK"}],
                                success: function(result) {
                                    $('#filtre_numero').keyup()
                                }
                            })
                        },
                        error: function(data) {
                            alert('erreur lors de la supression!')
                        }
                    })
                }
            }
        });

    }
    {% endif %}
</script>{# empty Twig template #}
